<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app"></div>

  <template id="my-app">
    您的问题：<input type="text" v-model="question">
    <button @click="queryAnswer">查找答案</button>
  </template>

  <script src="../js/vue.js"></script>
  <script>
    const App = {
      template: "#my-app",
      data() {
        return {
          question: "Hello World",
          answer: "",
        }
      },
      methods: {
        queryAnswer() {
          console.log(`您的问题${this.question}的答案是 哈哈哈`);
        }
      },
      watch: {
        question(newValue, oldValue) {
          console.log(`新值: ${newValue}, 旧值: ${oldValue}`);
          this.queryAnswer();
        }

      },
    };

    Vue.createApp(App).mount("#app");
  </script>
</body>

</html>